<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="简历姓名" prop="resumeName">
            <el-input
              v-model="queryParams.all"
              placeholder="请输入简历姓名"
              style="width: 200px"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:resume:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>


    <!--简历列表展示-->
    <el-table v-loading="loading" :data="resumeList" @selection-change="handleSelectionChange">
      <!--      <el-table-column label="简历id" align="center" prop="resumeId" />-->
      <el-table-column width="100" label="简历姓名" align="center" prop="resumeName"/>
      <el-table-column width="160" :show-overflow-tooltip="true" label="适合岗位" align="center" prop="expectStation"/>
      <el-table-column width="50" label="年龄" prop="age" align="center"/>
      <el-table-column width="120" label="工作经验（年）" align="center" prop="workyear">
        <template slot-scope="scope">
          {{ scope.row.workyear }}
        </template>
      </el-table-column>
      <el-table-column width="120" label="电话" align="center" prop="phone"/>
      <el-table-column width="80" prop="currentState" label="在职状态" align="center"/>
      <el-table-column width="110" :show-overflow-tooltip="true" prop="college" label="毕业院校" align="center"/>
      <el-table-column width="110"  :show-overflow-tooltip="true" prop="major" label="专业" align="center"/>
      <el-table-column width="80" label="期望薪资" prop="expectWage" align="center"/>
      <el-table-column width="100" label="期望工作地点" prop="workplace" align="center"/>
      <el-table-column width="200" :show-overflow-tooltip="true" prop="opinion" label="初审意见" align="center"/>
      <el-table-column width="80" label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0">
            <el-tag type="info">未投递</el-tag>
          </span>
          <span v-if="scope.row.status == 1">
             <el-tag type="primary">已投递</el-tag>
          </span>
          <span v-if="scope.row.status == 2">
             <el-tag type="warning">待录用</el-tag>
          </span>
          <span v-if="scope.row.status == 3">
             <el-tag type="success">待入职</el-tag>
          </span>
          <span v-if="scope.row.status == 6">
             <el-tag type="success">已入职</el-tag>
          </span>
          <span v-if="scope.row.status == 4">
             <el-tag type="danger">已离职</el-tag>
          </span>
          <span v-if="scope.row.status == 11">
             <el-tag type="warning">放弃入职</el-tag>
          </span>
        </template>
      </el-table-column>
      <el-table-column width="130" label="创建时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" label="创建人" align="center" prop="createName"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-eleme"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:resume:remove']"
          >恢复
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-management"
            @click="getResume(scope.row.resumeId)"
            v-hasPermi="['system:resume:query']"
          >详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


    <!-- 简历详情对话框 -->
    <el-dialog :title="title" :visible.sync="videoVisibles" width="90%" append-to-body  border>
      <el-descriptions class="margin-top" :column="5" size="medium" border>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              简历名称
            </center>

          </template>
          <center>
            {{ itoResume.resumeName }}
          </center>

        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              性别
            </center>
          </template>
          <center>
            {{ itoResume.sex }}
          </center>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              年龄
            </center>
          </template>
          <center>
            {{ itoResume.age }}
          </center>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              学历
            </center>
          </template>
          <center>
            {{ itoResume.education }}
          </center>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              电话
            </center>
          </template>
          <center>
            {{ itoResume.phone }}
          </center>
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              工作经验(年限)
            </center>
          </template>
          <center>{{ itoResume.workyear }}</center>

        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center>
              <i class="el-icon-user"></i>
              邮箱
            </center>

          </template>
          <center>{{ itoResume.mailbox }}</center>

        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              期望岗位
            </center>

          </template>
          <center>{{ itoResume.expectStation }}</center>

        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              期望薪资(K)
            </center>

          </template>
          <center>{{ itoResume.expectWage }}</center>

        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <center><i class="el-icon-user"></i>
              工作地点
            </center>

          </template>
          <center>{{ itoResume.workplace }}</center>

        </el-descriptions-item>
        <el-descriptions-item :span="1">
          <template slot="label">
            <center><i class="el-icon-user"></i>
              创建时间
            </center>

          </template>
          <center>{{ parseTime(itoResume.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</center>
        </el-descriptions-item>
        <el-descriptions-item :span="1">
          <template slot="label">
            <center><i class="el-icon-user"></i>
              毕业院校
            </center>

          </template>
          <center>{{ itoResume.college }}</center>
        </el-descriptions-item>
        <el-descriptions-item :span="1">
          <template slot="label">
            <center><i class="el-icon-user"></i>
              所学专业
            </center>

          </template>
          <center>{{ itoResume.major }}</center>
        </el-descriptions-item>
        <el-descriptions-item :span="1">
          <template slot="label">
            <center><i class="el-icon-user"></i>
              在职状态
            </center>

          </template>
          <center>{{ itoResume.currentState }}</center>
        </el-descriptions-item>
        <el-descriptions-item :span="1">
          <template slot="label">
            <center><i class="el-icon-user"></i>
              初审意见
            </center>

          </template>
          <center>{{ itoResume.opinion }}</center>
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions class="margin-top" size="medium" direction="vertical" :column="4" border>

        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            专业技能
          </template>
          <span v-html="itoResume.professionalSkill"></span>
        </el-descriptions-item>

        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            工作经历
          </template>
          <span v-html="itoResume.workeUndergo"></span>
        </el-descriptions-item>
        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            项目经验
          </template>
          <span v-html="itoResume.projectUndergo"></span>
        </el-descriptions-item>
        <el-descriptions-item :span="4">
          <template slot="label">
            <i class="el-icon-user"></i>
            教育背景
          </template>
          <span v-html="itoResume.educationalBackground"></span>
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
// 引用组件
import {
  listResume,
  getResume,
  hisResume,
} from "@/api/system/resHistory";
import ViewPdf from '@/components/pdf/ViewPdf'
import Test from "@/components/pdf/Test";

export default {
  name: "Resume",
  data() {
    return {
      intervalId: null,
      filename: '',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 简历表格数据
      resumeList: [],
      // 岗位表格数据
      stationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      videoVisible: false,
      videoStation: false,
      // 是否显示弹出层
      opens: false,
      videoVisibles: false,
      // 查询参数
      itoResume: {
        resumeId: null,
        resumeName: null,
        sex: null,
        age: null,
        imgPath: null,
        education: null,
        phone: null,
        workyear: null,
        mailbox: null,
        expectStation: null,
        expectWage: null,
        workplace: null,
        professionalSkill: null,
        workeUndergo: null,
        projectUndergo: null,
        educationalBackground: null,
        selfEvaluate: null,
        status: null,
        isDelete: 1,

      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        resumeId: null,
        resumeName: null,
        sex: null,
        age: null,
        imgPath: null,
        education: null,
        phone: null,
        workyear: null,
        mailbox: null,
        expectStation: null,
        expectWage: null,
        workplace: null,
        professionalSkill: null,
        workeUndergo: null,
        projectUndergo: null,
        educationalBackground: null,
        selfEvaluate: null,
        status: null,
        isDelete: 1,
        lowAge: undefined,
        tallAge: undefined,
        lowWage: undefined,
        tallWage: undefined,
        lowWorkyear: undefined,
        tallWorkyear: undefined,
        all:''
      },

      // 表单参数
      form: {
        resumeId: null,
        resumeName: null,
        sex: null,
        age: undefined,
        imgPath: null,
        education: null,
        phone: null,
        workyear: undefined,
        mailbox: null,
        expectStation: null,
        expectWage: undefined,
        workplace: null,
        professionalSkill: null,
        workeUndergo: null,
        projectUndergo: null,
        educationalBackground: null,
        selfEvaluate: null,
        status: null,
        isDelete: 1,
        lowAge: undefined,
        tallAge: undefined,
        lowWage: undefined,
        tallWage: undefined,
        lowWorkyear: undefined,
        tallWorkyear: undefined
      },
      // 表单校验
      rules: {},
      newPath: null,
      filePaths: [],
      resumeIds: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {

    /** 查询【请填写功能名称】列表 */
    getList(resumeId) {
      this.loading = true;
      listResume(this.queryParams).then(response => {
        this.resumeList = response.rows;
        this.total = response.total;
      });
      this.loading = false;
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancela() {
      this.open = false;
      this.reseta();
    },
    // 表单重置
    reset() {

      this.form = {
        resumeId: null,
        resumeName: null,
        sex: null,
        age: undefined,
        imgPath: null,
        education: null,
        phone: null,
        workyear: undefined,
        mailbox: null,
        expectStation: null,
        expectWage: undefined,
        workplace: null,
        professionalSkill: null,
        workeUndergo: null,
        projectUndergo: null,
        educationalBackground: null,
        selfEvaluate: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        status: null,
        isDelete: "1",
        lowAge: undefined,
        tallAge: undefined,
        lowWage: undefined,
        tallWage: undefined,
        lowWorkyear: undefined,
        tallWorkyear: undefined
      };
      this.resetForm("form");
    },
    // 表单重置
    reseta() {
      this.form = {};
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {isDelete: "1"};
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.resumeId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    /** 恢复按钮操作 */
    handleDelete(row) {
      const resumeId = row.resumeId || this.ids || this.itoResume.resumeId;
      this.$modal.confirm('是否确认恢复这条的数据项？').then(function () {
        return hisResume(resumeId);
      }).then(() => {
        this.$modal.msgSuccess("恢复成功");
        this.getList()
      }).catch(() => {
      });
    },


    /** 详情按钮操作 */
//点击按钮时,触发弹出效果
    getResume(resumeId) {
      getResume(resumeId).then(response => {
        this.itoResume = response.data;
        //触发点击时,让其显示
        this.videoVisibles = true
        this.title="简历详情"
      });
    }
    ,
//事件操作 (表格、表单 同理 需要执行的事件 在此处)
    closeDialog() {
      this.getList();
    }
    ,

    /** 详情按钮操作 */
//点击按钮时,触发弹出效果
    playVideStation(stationId) {
      getStation(stationId).then(response => {
        this.queryStationParams = response.data;
        this.videoStation = true
      });
    }
    ,

    /** 导出按钮操作 */
    handleExport() {
      this.download('/system/resume/export/1', {
        ...this.queryParams
      }, `resume_${new Date().getTime()}.xlsx`)
    }
  }
}

</script>

<style>
* {
  margin: 0;
  padding: 0;
}
html,
body {
  width: 100%;
  height: 100%;
}
</style>
